//
//  TTZuanshiView.m
//  TaoTuo
//
//  Created by LG on 2020/10/14.
//  Copyright © 2020 刘广. All rights reserved.
//

#import "TTZuanshiView.h"
#import "TTZuanshiLeftView.h"
#import "TTSearchInsertModel.h"
#import "TTSearchModel.h"
#import "TTSearchViewController.h"

@interface TTZuanshiView ()

@property (nonatomic, strong) TTZuanshiLeftView *leftView;
@property (nonatomic, strong) NSMutableArray *hotArray;

@end

@implementation TTZuanshiView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = UIColorHex(#F5F5F5);
        [self setupSubviews];
        
        
        
    }
    return self;
}

- (NSDictionary *)getParamsDic
{
    NSDictionary *dic = [self.rightView getParamsDic];
    
//    self.rightView.searchModel.searchKey = self.searchTF.text;
    
//    NSDictionary *dic = [self.rightView.searchModel modelToDic];
    
    return dic;
}

/// 搜索
- (void)searchBtnClick
{
    TTSearchViewController *searchVC = [[TTSearchViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:searchVC];
    nav.modalPresentationStyle = UIModalPresentationFullScreen;
    nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [[LLRouteTool getCurrentNavigationController] presentViewController:nav animated:YES completion:nil];
    
}

- (void)setupSubviews
{
    _searchTF = [[LLSearchTextField alloc] initWithFrame:CGRectMake(23, 10, self.width - 23 * 2, 30)];
    _searchTF.backgroundColor = UIColorHex(EDEBFF);
    _searchTF.enabled = NO;
    _searchTF.returnKeyType = UIReturnKeyDefault;
    _searchTF.placeholder = @"输入 成品/系列/品牌 搜索";
    _searchTF.backgroundColor = UIColor.whiteColor;
    [self addSubview:_searchTF];
    UIButton *searchBtn = [UIButton createButtonWithTitle:@"" titleColor:nil titleFont:nil backgroundColor:nil target:self action:@selector(searchBtnClick)];
    searchBtn.frame = _searchTF.bounds;
    [self addSubview:searchBtn];
    
    
    NSArray *array = @[@"女戒", @"套链", @"对戒", @"男戒", @"吊坠", @"手链", @"手镯", @"耳钉", @"耳线", @"耳坠"];
    self.leftView = [[TTZuanshiLeftView alloc] initWithFrame:CGRectMake(0, 50, 90, self.height - 50)];
    [self addSubview:self.leftView];
    @weakify(self)
    self.leftView.selectBlock = ^(NSString * _Nonnull name) {
        @strongify(self)
        [[NSNotificationCenter defaultCenter] postNotificationName:@"zuanshiViewCategoryNameChanged_key" object:@([array indexOfObject:name] + 1)];
        [self.rightView resetViews];
        self.rightView.searchModel.categoryName = name;
        [self.rightView setSearchNameDicWithKey:@"0" value:name];
        [self.rightView setupViewsWithName:name];
    };
    self.leftView.dataArray = array;
    
    self.rightView = [[TTZuanshiRightView alloc] initWithFrame:CGRectMake(90, self.leftView.top, self.width - 90, self.leftView.height)];
    [self addSubview:self.rightView];
    
}

- (void)resetView
{
    [self.rightView resetViews];
}


#pragma mark - JXCategoryListContentViewDelegate
- (UIView *)listView
{
    return self;
}

@end
